import request from '../utils/request'
import storageService from '../utils/storageService'
import {URL} from '../utils/url'
import axios from 'axios'

//获取系统通知
export function getSysMsg() {
    return request.get('message/announce')
}

//获取私信列表
export function getUserMsgList(){
    const url = URL + 'api/message/list'
    const headers ={
        'Authorization': 'Bearer ' + storageService.get(storageService.USER_TOKEN)
    }
    return axios.get(url,{
      headers:headers
    }).then(res => {
      return Promise.resolve(res)
    })
}

//获取私信内容
export function GetUserMessageById(fid){
  const url = URL + 'api/message/get'
  const data ={
    'fid': fid
  }
  const headers ={
    'Authorization': 'Bearer ' + storageService.get(storageService.USER_TOKEN)
  }
  return axios.get(url,{
    params: data,
    headers:headers
  }).then(res => {
    return Promise.resolve(res)
  })
}

export function sendMsg({fid,content}) {
  return request.post('message/send',{fid,content})
}